package org.example;

import org.example.bean.Orders;
import org.example.bean.product;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.Date;
import java.util.concurrent.Executor;

public class App2 {
        public static void main(String[] args){

            ApplicationContext ac = new AnnotationConfigApplicationContext(AppConfig2.class);
            Orders orders=(Orders) ac.getBean("orders");
            System.out.println(orders);

            product product=(product) ac.getBean("p1");
            System.out.println(product);


            Executor executor=(Executor) ac.getBean("threadPool");
            executor.execute(()->{
                while (true){
                    try {
                        Thread.sleep(100);
                    }catch (InterruptedException e){
                        throw new RuntimeException(e);
                    }
                    System.out.println( new Date());
                }
            });


        }
}
